﻿namespace EFS.RC.CommunicatorContext.Operators
{
	public partial class Questionnaire : EFS.RC.CommunicatorContext.Common.Pages.Controls.Control
	{
		public class Item { public System.String Name { get; set; } public System.String Code { get; set; } }

		#region Delegates
		/// SelectionChanged
		public delegate void SelectionChangedDelegate(System.String newSelectionCode);
		public SelectionChangedDelegate SelectionChanged;
		#endregion

		public Questionnaire()
		{
			InitializeComponent();

			// ignore in design tool
			if (!System.ComponentModel.DesignerProperties.IsInDesignTool)
			{
			}
		}

		#region Properties

		/// Property SelectedCode: Get
		public System.String SelectedCode
		{
			get
			{
				// test
				if (null != comboBoxQuestionnaire.SelectedValue)
				{
					// ID
					return (System.String)comboBoxQuestionnaire.SelectedValue;
				}

				// none
				return null;
			}
		}

		/// Property ReadOnly: Get, Set
		public System.Boolean ReadOnly
		{
			get
			{
				return !comboBoxQuestionnaire.IsEnabled;
			}
			set
			{
				comboBoxQuestionnaire.IsEnabled = !value;
			}
		}

		#endregion

		#region Usage

		/// <summary>
		/// Load 
		/// </summary>
		/// <param name="lineId"></param>
		private void LoadData()
		{
			comboBoxQuestionnaire.ItemsSource =
				new Item[]
				{
					new Item { Code = "", Name = "Select to start" },
					new Item { Code = EFS.RC.CC.Messages.Communicator.Lync.Context.Questionnaire.Codes.One, Name = "Start Questionnaire" }
				};
			comboBoxQuestionnaire.SelectedIndex = 0;
		}

		#endregion

		#region Events
		/// Loaded
		private void Control_Loaded(object sender, System.Windows.RoutedEventArgs e)
		{
			// ignore in designer
			if (System.ComponentModel.DesignerProperties.IsInDesignTool)
			{
				return;
			}

			// load data
			LoadData();
		}

		/// Selection changed
		private void comboBoxQuestionnaire_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
		{
			// notify all registered
			if (null != this.SelectionChanged)
			{
				this.SelectionChanged(SelectedCode);
			}
		}
		#endregion
	}

}